<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('收益列表')"/>
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="formId">
                <div class="select-list">
                    <ul>
                        <li>
                            <label>分润级别：</label>
                            <select name="shareLevel" th:with="type=${@dict.getType('income_share_level')}">
                                <option value="">所有</option>
                                <option th:each="dict : ${type}" th:text="${dict.dictLabel}"
                                        th:value="${dict.dictValue}"></option>
                            </select>
                        </li>
                        <li>
                            <label>收益来源：</label>
                            <select name="incomeType" th:with="type=${@dict.getType('income_types')}">
                                <option value="">所有</option>
                                <option th:each="dict : ${type}" th:text="${dict.dictLabel}"
                                        th:value="${dict.dictValue}"></option>
                            </select>
                        </li>
                        <li class="select-time">
                            <label>分成时间：</label>
                            <input type="text" class="time-input" id="startTime" placeholder="开始时间"
                                   name="startTime"/>
                            <span>-</span>
                            <input type="text" class="time-input" id="endTime" placeholder="结束时间"
                                   name="endTime"/>
                        </li>
                        <li>
                            <label style="width: 105px;">关键字查询字段：</label>
                            <select name="fields">
                                <option value="orderNumber" selected>租借订单号</option>
                            </select>
                            <input type="text" name="keywords"/>
                        </li>
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i
                                    class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i
                                    class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="btn-group-sm" id="toolbar" role="group">
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer"/>
<script th:inline="javascript">
    var editFlag = [[${@permission.hasPermi('system:income:edit')}]];
    var removeFlag = [[${@permission.hasPermi('system:income:remove')}]];
    var shareLevelDatas = [[${@dict.getType('income_share_level')}]];
    var incomeTypeDatas = [[${@dict.getType('income_types')}]];
    var prefix = ctx + "system/income";

    $(function () {
        var options = {
            url: prefix + "/list",
            createUrl: prefix + "/add",
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/remove",
            exportUrl: prefix + "/export",
            modalName: "收益",
            columns: [{
                checkbox: true
            },
                {
                    field: 'id',
                    title: '收益iD',
                    visible: false
                },
                {
                    field: 'directPartnerName',
                    title: '直营合作商'
                },
                {
                    field: 'orderNumber',
                    title: '租借订单号'
                },
                {
                    field: 'projectName',
                    title: '项目名',
                    formatter: function (value, row, index) {
                        // 分润级别 1 平台 2 合作商 3 商户
                        var str = "";
                        if (row.shareLevel == 1) {
                            str = "<span style='color: red;'>" + value + "</span>";
                        } else {
                            str = value;
                        }
                        return str;
                    }
                },
                {
                    field: 'partnerName',
                    title: '合作商名',
                    formatter: function (value, row, index) {
                        // 分润级别 1 平台 2 合作商 3 商户
                        var str = "";
                        if (row.shareLevel == 2) {
                            str = "<span style='color: red;'>" + value + "</span>";
                        } else {
                            str = value;
                        }
                        return str;
                    }
                },
                {
                    field: 'merchantName',
                    title: '商户名',
                    formatter: function (value, row, index) {
                        // 分润级别 1 平台 2 合作商 3 商户
                        var str = "";
                        if (row.shareLevel == 3) {
                            str = "<span style='color: red;'>" + value + "</span>";
                        } else {
                            str = value;
                        }
                        return str;
                    }
                },
                {
                    field: 'storeName',
                    title: '门店名(收益来源)'
                },
                {
                    field: 'totalAmount',
                    title: '分润总金额'
                },
                {
                    field: 'shareLevel',
                    title: '分润级别',
                    formatter: function (value, row, index) {
                        return $.table.selectDictLabel(shareLevelDatas, value);
                    }
                },
                {
                    field: 'incomeType',
                    title: '收益类型',
                    formatter: function (value, row, index) {
                        return $.table.selectDictLabel(incomeTypeDatas, value);
                    }
                },
                {
                    field: 'shareTime',
                    title: '分成时间'
                },
                {
                    field: 'userAppId',
                    title: '用户昵称',
                    formatter: function (value, row, index) {
                        var imagesUrl = "";
                        if (row.avatar != null && row.avatar != "") {
                            imagesUrl = $.table.imageView(row.avatar);
                        }
                        return imagesUrl + "&nbsp;" + row.nickName;
                    }
                },
                {
                    field: 'shareBrokerage',
                    title: '分润比例'
                },
                {
                    field: 'shareMoney',
                    title: '分润金额',
                    formatter: function (value, row, index) {
                        return "<span style='color: green;'>" + value + "</span>";
                    }
                },
                {
                    field: 'beforeMoney',
                    title: '分润前金额'
                },
                {
                    field: 'afterMoney',
                    title: '分润后金额'
                },
                // {
                //     title: '操作',
                //     align: 'center',
                //     formatter: function (value, row, index) {
                //         var actions = [];
                //         actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                //         actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
                //         return actions.join('');
                //     }
                // }
            ]
        };
        $.table.init(options);
    });
</script>
</body>
</html>